package com.china08.yxyapi.config;

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * 配置 Servlet
 * 
 * @author Ertao.Fang
 *
 */
@Configuration
public class ServletConfig {

    @Bean
    EmbeddedServletContainerCustomizer containerCustomizer() {
        EmbeddedServletContainerCustomizer customizer = new EmbeddedServletContainerCustomizer() {

            @Override
            public void customize(ConfigurableEmbeddedServletContainer container) {
                container.addErrorPages(new ErrorPage("/error"));
                container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/404"));
            }
        };
        return customizer;
    }

}
